<!DOCTYPE html>
<html class="Content">
<head>
    <title>xUnit.js: Facts &amp; Fixtures</title>
    <link type="text/css" rel="Stylesheet" href="../../Style/documentation.css" />
</head>
<body>
    <h1>Facts &amp; Fixtures</h1>
    <p>
        xUnit.js borrows the concepts of <strong>Facts</strong> from <a href="http://xunit.codeplex.com/">xUnit.net</a>, 
        to remind developers to only test a single behavioral promise at a time. Consequently, facts should be named after 
        the promise of behavior that they exercise, without a prefix or suffix of "test", e.g.:
        <span class="Code">
function ComparesTrueAndNotFalse(){
    // Arrange
    var expected=true;

    // Act
    var actual=!false;

    //Assert
    Assert.Equal(expected,actual);
}
        </span>

    </p>
    <p>
        Facts are organized and grouped in <strong>Fixtures</strong>, to encapsulate tests for common behaviors or APIs. 
        Fixtures are <strong>xUnit.js.Model.IRunnable</strong> containers that execute all of their registered Fixtures and Facts recursively when run.
        A common organization of nested Fixtures is:
    </p>
    <ul>
        <li class="Indent-1">Class</li>
        <li class="Indent-2">Method</li>
        <li class="Indent-3"title="Optional">[Behavior]</li>
        <li class="Indent-2" title="Optional">[Behavior]</li>
    </ul>
    <p>e.g.:</p>
    <ul>
        <li class="Indent-1">Test.xUnit.js.Assert</li>
        <li class="Indent-2">Equals</li>
        <li class="Indent-3"title="Optional">[ArrayComparisons]</li>
        <li class="Indent-3"title="Optional">[ObjectComparisons]</li>
    </ul>
    <p>
        xUnit.js is designed to facilitate common testing patterns, such as <strong>Arrange-Act-Assert</strong>, <strong>Single-Assert</strong>, and <strong>Promise-Naming</strong>. 
        While it is not necessary to follow these patterns, it is highly encouraged, as they facilitate test comprehension and maintenance by standardizing the shape of the 
        facts being tested. 
    </p>
    <p>    
        It is also encouraged to standardize three variables: <strong>expected</strong>, <strong>target</strong>, and <strong>actual</strong>, and to exclude as much logic as possible 
        from the <em>Act</em> and <em>Assert</em> steps. In this way, the test can be read most efficiently backwards, Assert-Act-Arrange, and the shape of the test becomes intuitively clear before 
        any higher-order comprehension is required to grok the logic in the setup.
    </p>
</body>
</html>